Page({
  data: {
    goodsImageUrl:'',
    goodsId:'',
  },

  

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (e) {
    let that = this;
    const eventChannel = this.getOpenerEventChannel()
    eventChannel.on('onToAward',function(data){
      that.setData({
           goodsImageUrl:data.data.imageUrl,
           goodsId:data.data.id,
       })
    })
  },

  //预览图片的方法
  clickImg(){
    let that = this;
    wx.previewImage({
      current:that.data.goodsImageUrl,
      urls: [that.data.goodsImageUrl],
      success: function (res) { },
      fail: function (res) { },
      complete: function (res) { },
    })
  },

  //将goodsId传值给checkout页面
  onToCheckout: function(event) {
    let that = this;
    wx.navigateTo({
      url: '/pages/checkout/checkout',
      success:function(res) {
        res.eventChannel.emit('onToCheckout', {
          data:{
            goodsId:that.data.goodsId,
          }
        })
      }
    })
  },
  
  onShow: function() {
    // Do something when page show.
  },
  onReady: function() {
    // Do something when page ready.
  },
  onHide: function() {
    // Do something when page hide.
  },
  onUnload: function() {
    // Do something when page close.
  },
  onPullDownRefresh: function() {
    // Do something when pull down.
  },
  onReachBottom: function() {
    // Do something when page reach bottom.
  },
  onShareAppMessage: function () {
    // return custom share data when user share.
  },
  onPageScroll: function() {
    // Do something when page scroll
  },
  onResize: function() {
    // Do something when page resize
  }
})
